package com.fastdfs.destroy;

import org.csource.fastdfs.StorageClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PreDestroy;
import java.io.IOException;

/**
 * Description
 * Author wangxh
 * Date 2020/7/17-2:24 下午
 * Version V1.0
 **/

@Component
public class FastDFSDestroy {

    private static final Logger logger = LoggerFactory.getLogger(FastDFSDestroy.class);

    @Autowired
    StorageClient storageClient;

    @PreDestroy
    public void destroy () {
        logger.info("FastDFS连接销毁 - start");
        if(null != storageClient){
            try {
                storageClient.close();
                logger.info("FastDFS连接销毁 - close");
            } catch (IOException e) {
                e.printStackTrace();
                logger.error("FastDFS连接销毁",e);
            }
        }
        logger.info("FastDFS连接销毁 - end");
    }

}
